<!DOCTYPE HTML>
<html lang="en" >
    
    <head>
        
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <title>Mysql基础 | Introduction</title>
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <meta name="description" content="">
        <meta name="generator" content="GitBook 2.6.7">
        
        
        <meta name="HandheldFriendly" content="true"/>
        <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
        <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">
        
    <link rel="stylesheet" href="../../gitbook/style.css">
    
        
        <link rel="stylesheet" href="../../gitbook/plugins/gitbook-plugin-highlight/website.css">
        
    
        
        <link rel="stylesheet" href="../../gitbook/plugins/gitbook-plugin-search/search.css">
        
    
        
        <link rel="stylesheet" href="../../gitbook/plugins/gitbook-plugin-fontsettings/website.css">
        
    
    

        
    
    
    <link rel="next" href="../../home/part1/1.MySQL基础操作.html" />
    
    
    <link rel="prev" href="../../home/MySQL介绍.html" />
    

        
    </head>
    <body>
        
        
    <div class="book"
        data-level="2"
        data-chapter-title="Mysql基础"
        data-filepath="home/part1/MySQL基础.md"
        data-basepath="../.."
        data-revision="Sun Oct 21 2018 16:32:53 GMT+0800 (中国标准时间)"
        data-innerlanguage="">
    

<div class="book-summary">
    <nav role="navigation">
        <ul class="summary">
            
            
            
            

            

            
    
        <li class="chapter " data-level="0" data-path="index.html">
            
                
                    <a href="../../index.html">
                
                        <i class="fa fa-check"></i>
                        
                        Introduction
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1" data-path="home/MySQL介绍.html">
            
                
                    <a href="../../home/MySQL介绍.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.</b>
                        
                        MySQL介绍
                    </a>
            
            
        </li>
    
        <li class="chapter active" data-level="2" data-path="home/part1/MySQL基础.html">
            
                
                    <a href="../../home/part1/MySQL基础.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.</b>
                        
                        Mysql基础
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1" data-path="home/part1/1.MySQL基础操作.html">
            
                
                    <a href="../../home/part1/1.MySQL基础操作.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.1.</b>
                        
                        MySQL基础操作
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.2" data-path="home/part1/2.MySQL数据类型.html">
            
                
                    <a href="../../home/part1/2.MySQL数据类型.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.2.</b>
                        
                        MySQL数据类型
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.3" data-path="home/part1/3.MySQL建库建表.html">
            
                
                    <a href="../../home/part1/3.MySQL建库建表.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.3.</b>
                        
                        MySQL建库建表
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.4" data-path="home/part1/4.DML操作：增,删,改.html">
            
                
                    <a href="../../home/part1/4.DML操作：增,删,改.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.4.</b>
                        
                        DML操作：增,删,改
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.5" data-path="home/part1/5.DQL操作：数据查询.html">
            
                
                    <a href="../../home/part1/5.DQL操作：数据查询.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.5.</b>
                        
                        DQL操作：数据查询
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.6" data-path="home/part1/6.数据导入和导出.html">
            
                
                    <a href="../../home/part1/6.数据导入和导出.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.6.</b>
                        
                        数据导入和导出
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3" data-path="home/part2/MySQL高级.html">
            
                
                    <a href="../../home/part2/MySQL高级.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.</b>
                        
                        MySQL高级
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.1" data-path="home/part2/1.MySQL的多表联查.html">
            
                
                    <a href="../../home/part2/1.MySQL的多表联查.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.1.</b>
                        
                        MySQL的多表联查
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.2" data-path="home/part2/2.MySQL的事务处理.html">
            
                
                    <a href="../../home/part2/2.MySQL的事务处理.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.2.</b>
                        
                        MySQL的事务处理
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.3" data-path="home/part2/3.MySQL的视图及其它.html">
            
                
                    <a href="../../home/part2/3.MySQL的视图及其它.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.3.</b>
                        
                        MySQL的视图及其它
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.4" data-path="home/part2/4.MySQL的触发器.html">
            
                
                    <a href="../../home/part2/4.MySQL的触发器.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.4.</b>
                        
                        MySQL的触发器
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.5" data-path="home/part2/6.MySQL日志及数据恢复.html">
            
                
                    <a href="../../home/part2/6.MySQL日志及数据恢复.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.5.</b>
                        
                        MySQL日志及数据恢复
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.6" data-path="home/part2/7.慢查询及sql优化.html">
            
                
                    <a href="../../home/part2/7.慢查询及sql优化.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.6.</b>
                        
                        慢查询及sql优化
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4" data-path="home/part3/Python连接MySQL.html">
            
                
                    <a href="../../home/part3/Python连接MySQL.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.</b>
                        
                        Python连接MySQL
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.1" data-path="home/part3/1.CRUD.html">
            
                
                    <a href="../../home/part3/1.CRUD.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.1.</b>
                        
                        CRUD
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    


            
            <li class="divider"></li>
            <li>
                <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
                    Published with GitBook
                </a>
            </li>
            
        </ul>
    </nav>
</div>

    <div class="book-body">
        <div class="body-inner">
            <div class="book-header" role="navigation">
    <!-- Actions Left -->
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../../" >Introduction</a>
    </h1>
</div>

            <div class="page-wrapper" tabindex="-1" role="main">
                <div class="page-inner">
                
                
                    <section class="normal" id="section-">
                    
                        <h1 id="mysql&#x57FA;&#x7840;">MySQL&#x57FA;&#x7840;</h1>
<hr>
<blockquote>
<p>&#x719F;&#x7EC3;&#x638C;&#x63E1;MySQL&#x7684;&#x5B89;&#x88C5;&#x53CA;&#x57FA;&#x7840;&#x4F7F;&#x7528;</p>
</blockquote>
<ul>
<li><h2 id="&#x5728;ubuntu1604&#x4E0B;&#x5B89;&#x88C5;mysql">&#x5728;Ubuntu16.04&#x4E0B;&#x5B89;&#x88C5;MySQL</h2>
<ul>
<li><h3 id="&#x9996;&#x5148;&#x6267;&#x884C;&#x4E0B;&#x9762;&#x4E09;&#x6761;&#x547D;&#x4EE4;&#xFF1A;">&#x9996;&#x5148;&#x6267;&#x884C;&#x4E0B;&#x9762;&#x4E09;&#x6761;&#x547D;&#x4EE4;&#xFF1A;</h3>
<pre><code class="lang-bash">  sudo apt-get install mysql-server

  sudo apt install mysql-client

  sudo apt install libmysqlclient-dev
</code></pre>
</li>
<li><h3 id="&#x5B89;&#x88C5;&#x6210;&#x529F;&#x540E;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x4E0B;&#x9762;&#x7684;&#x547D;&#x4EE4;&#x6D4B;&#x8BD5;&#x662F;&#x5426;&#x5B89;&#x88C5;&#x6210;&#x529F;">&#x5B89;&#x88C5;&#x6210;&#x529F;&#x540E;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x4E0B;&#x9762;&#x7684;&#x547D;&#x4EE4;&#x6D4B;&#x8BD5;&#x662F;&#x5426;&#x5B89;&#x88C5;&#x6210;&#x529F;</h3>
<pre><code class="lang-bash">  sudo  netstat -tap | grep mysql
</code></pre>
</li>
<li><h3 id="&#x51FA;&#x73B0;&#x5982;&#x4E0B;&#x4FE1;&#x606F;&#x8BC1;&#x660E;&#x5B89;&#x88C5;&#x6210;&#x529F;">&#x51FA;&#x73B0;&#x5982;&#x4E0B;&#x4FE1;&#x606F;&#x8BC1;&#x660E;&#x5B89;&#x88C5;&#x6210;&#x529F;</h3>
<pre><code class="lang-bash">  tcp6       <span class="hljs-number">0</span>      <span class="hljs-number">0</span> [::]:mysql              [::]:*                  LISTEN      
  <span class="hljs-number">1123</span>/mysqld
</code></pre>
</li>
<li><h3 id="&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x5982;&#x4E0B;&#x547D;&#x4EE4;&#x8FDB;&#x5165;mysql&#x670D;&#x52A1;">&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x5982;&#x4E0B;&#x547D;&#x4EE4;&#x8FDB;&#x5165;mysql&#x670D;&#x52A1;</h3>
<pre><code class="lang-sql">  mysql -uroot -p&#x4F60;&#x7684;&#x5BC6;&#x7801;
</code></pre>
</li>
<li><h3 id="&#x8BBE;&#x7F6E;mysql&#x5141;&#x8BB8;&#x8FDC;&#x7A0B;&#x8BBF;&#x95EE;">&#x8BBE;&#x7F6E;mysql&#x5141;&#x8BB8;&#x8FDC;&#x7A0B;&#x8BBF;&#x95EE;</h3>
<pre><code class="lang-bash">  sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf

  &#x6CE8;&#x91CA;&#x6389;<span class="hljs-built_in">bind</span>-address = <span class="hljs-number">127.0</span>.<span class="hljs-number">0.1</span>&#xFF1A;
</code></pre>
</li>
<li><h3 id="&#x4FDD;&#x5B58;&#x9000;&#x51FA;&#xFF0C;&#x7136;&#x540E;&#x8FDB;&#x5165;mysql&#x670D;&#x52A1;&#xFF0C;&#x6267;&#x884C;&#x6388;&#x6743;&#x547D;&#x4EE4;">&#x4FDD;&#x5B58;&#x9000;&#x51FA;&#xFF0C;&#x7136;&#x540E;&#x8FDB;&#x5165;mysql&#x670D;&#x52A1;&#xFF0C;&#x6267;&#x884C;&#x6388;&#x6743;&#x547D;&#x4EE4;</h3>
<pre><code class="lang-sql">  <span class="hljs-operator"><span class="hljs-keyword">grant</span> all <span class="hljs-keyword">on</span> *.* <span class="hljs-keyword">to</span> root@<span class="hljs-string">&apos;%&apos;</span> <span class="hljs-keyword">identified</span> <span class="hljs-keyword">by</span> <span class="hljs-string">&apos;123456&apos;</span> <span class="hljs-keyword">with</span> <span class="hljs-keyword">grant</span> <span class="hljs-keyword">option</span>;</span>

  &#x5237;&#x65B0;&#x751F;&#x6548;&#xFF0C;&#x5426;&#x5219;&#x5C31;&#x8981;&#x91CD;&#x542F;MySQL&#x670D;&#x52A1;&#x624D;&#x53EF;&#x4EE5;
  <span class="hljs-operator"><span class="hljs-keyword">flush</span> <span class="hljs-keyword">privileges</span>;</span>
</code></pre>
</li>
<li><h3 id="&#x7136;&#x540E;&#x6267;&#x884C;quit&#x547D;&#x4EE4;&#x9000;&#x51FA;mysql&#x670D;&#x52A1;&#xFF0C;&#x6267;&#x884C;&#x5982;&#x4E0B;&#x547D;&#x4EE4;&#x91CD;&#x542F;mysql">&#x7136;&#x540E;&#x6267;&#x884C;quit&#x547D;&#x4EE4;&#x9000;&#x51FA;mysql&#x670D;&#x52A1;&#xFF0C;&#x6267;&#x884C;&#x5982;&#x4E0B;&#x547D;&#x4EE4;&#x91CD;&#x542F;mysql</h3>
<pre><code class="lang-sql">  service mysql restart
</code></pre>
</li>
</ul>
</li>
<li><h2 id="&#x5728;windows&#x4E0B;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;navicat&#x8FDC;&#x7A0B;&#x8FDE;&#x63A5;ubuntu&#x4E0B;&#x7684;mysql&#x670D;&#x52A1;">&#x5728;windows&#x4E0B;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;navicat&#x8FDC;&#x7A0B;&#x8FDE;&#x63A5;ubuntu&#x4E0B;&#x7684;mysql&#x670D;&#x52A1;</h2>
<p>  <img src="../images/Navicat.png" alt=""></p>
<ul>
<li>&#x8FDE;&#x63A5;&#x540D;&#xFF1A;&#x81EA;&#x5DF1;&#x5B9A;&#x4E49;</li>
<li>&#x4E3B;&#x673A;&#x540D;&#x6216;IP&#x5730;&#x5740;&#xFF1A;&#x5199;&#x81EA;&#x5DF1;Ubuntu&#x7684;ip&#x5730;&#x5740;</li>
<li>&#x7AEF;&#x53E3;&#xFF1A;3306</li>
<li>&#x7528;&#x6237;&#x540D;&#xFF1A;&#x5199;&#x81EA;&#x5DF1;Ubuntu&#x4E2D;MySQL&#x7684;&#x7528;&#x6237;&#x540D;</li>
<li><p>&#x5BC6;&#x7801;&#xFF1A;&#x5199;&#x81EA;&#x5DF1;Ubuntu&#x4E2D;MySQL&#x7684;&#x5BC6;&#x7801;</p>
</li>
<li><h3 id="&#x53EF;&#x80FD;&#x51FA;&#x73B0;&#x7684;&#x9519;&#x8BEF;">&#x53EF;&#x80FD;&#x51FA;&#x73B0;&#x7684;&#x9519;&#x8BEF;</h3>
<pre><code class="lang-bash">  Ubuntu&#x4E2D;&#x66F4;&#x65B0;&#x8F6F;&#x4EF6;&#x65F6;&#x7ECF;&#x5E38;&#x4F1A;&#x78B0;&#x5230;&#x4E00;&#x4E2A;&#x95EE;&#x9898;&#xFF1A;
  E: &#x65E0;&#x6CD5;&#x83B7;&#x5F97;&#x9501; /var/cache/apt/archives/lock - open (<span class="hljs-number">11</span> &#x8D44;&#x6E90;&#x4E34;&#x65F6;&#x4E0D;&#x53EF;&#x7528;)
  E: &#x65E0;&#x6CD5;&#x5BF9;&#x4E0B;&#x8F7D;&#x76EE;&#x5F55;&#x52A0;&#x9501;
  &#x9020;&#x6210;&#x8BE5;&#x95EE;&#x9898;&#x7684;&#x539F;&#x56E0;&#x662F;&#x7CFB;&#x7EDF;&#x4E2D;&#x53EA;&#x5141;&#x8BB8;&#x6709;&#x4E00;&#x4E2A;apt-get&#x8FDB;&#x7A0B;&#xFF0C;&#x5F53;&#x524D;&#x7684;&#x9501;&#x5DF2;&#x7ECF;&#x88AB;&#x5360;&#x7528;&#x4E86;&#x3002;
  &#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x5173;&#x6389;&#x5F53;&#x524D;&#x7684;apt-get&#x8FDB;&#x7A0B;&#x540E;&#xFF0C;&#x518D;&#x6267;&#x884C;&#x6211;&#x4EEC;&#x81EA;&#x5DF1;&#x7684;&#x64CD;&#x4F5C;&#x3002;
  &#x89E3;&#x51B3;&#x65B9;&#x6848;&#x4E00;&#xFF1A;
      &#x5148;&#x6267;&#x884C;&#x547D;&#x4EE4;ps aux | grep apt-get&#xFF0C;&#x627E;&#x51FA;&#x5F53;&#x524D;&#x7684;apt-get&#x8FDB;&#x884C;&#xFF0C;&#x7136;&#x540E;<span class="hljs-built_in">kill</span>&#x6389;&#x8BE5;&#x8FDB;&#x7A0B;&#x3002;
  &#x89E3;&#x51B3;&#x65B9;&#x6848;&#x4E8C;&#xFF1A;
      &#x76F4;&#x63A5;rm rm /var/cache/apt/archives/lock &#x548C; rm /var/lib/dpkg/lock&#x3002;
</code></pre>
</li>
</ul>
</li>
<li><h2 id="ubuntu1604&#x5B8C;&#x5168;&#x5378;&#x8F7D;mysql-57">Ubuntu16.04&#x5B8C;&#x5168;&#x5378;&#x8F7D;Mysql 5.7</h2>
<pre><code class="lang-bash">  sudo apt purge mysql-*

  sudo rm -rf /etc/mysql/ /var/lib/mysql

  sudo apt autoremove
</code></pre>
</li>
</ul>

                    
                    </section>
                
                
                </div>
            </div>
        </div>

        
        <a href="../../home/MySQL介绍.html" class="navigation navigation-prev " aria-label="Previous page: MySQL介绍"><i class="fa fa-angle-left"></i></a>
        
        
        <a href="../../home/part1/1.MySQL基础操作.html" class="navigation navigation-next " aria-label="Next page: MySQL基础操作"><i class="fa fa-angle-right"></i></a>
        
    </div>
</div>

        
<script src="../../gitbook/app.js"></script>

    
    <script src="../../gitbook/plugins/gitbook-plugin-search/lunr.min.js"></script>
    

    
    <script src="../../gitbook/plugins/gitbook-plugin-search/search.js"></script>
    

    
    <script src="../../gitbook/plugins/gitbook-plugin-sharing/buttons.js"></script>
    

    
    <script src="../../gitbook/plugins/gitbook-plugin-fontsettings/buttons.js"></script>
    

<script>
require(["gitbook"], function(gitbook) {
    var config = {"highlight":{},"search":{"maxIndexSize":1000000},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2}};
    gitbook.start(config);
});
</script>

        
    </body>
    
</html>
